//
//  AbstractTests.h
//  template_ios_project
//
//  Created by Lanlan Song on 12-3-27.
//  Copyright (c) 2012年 Cybercom. All rights reserved.
//

//  Logic unit tests contain unit test code that is designed to be linked into an independent test executable.
//  See Also: http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html

#import <SenTestingKit/SenTestingKit.h>

#define HC_SHORTHAND
#import "OCHamcrest.h"

#define MOCKITO_SHORTHAND
#import "OCMockito.h"

#define JS_CodeStopHere while (!isCodeStop) [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]
#define JS_CodeResume isCodeStop = YES

@interface AbstractTests : SenTestCase{
  @protected
  BOOL isCodeStop;
}

- (void)before;

- (void)after;

/**
 * Begins the async operation watch.
 * @discussion Call before async operation begins.
 */
- (void)beginAsyncOperation;

/**
 * Finishes the async operation watch, call to complete operation and prevent timeout.
 */
- (void)finishedAsyncOperation;

/**
 * Waits for the async operation to finish or returns as a timeout.
 * @return YES if the async operation timeout interval is exceeded, NO if the
 * async operation finished.
 */
- (BOOL)waitForAsyncOperationOrTimeoutWithInterval:(NSTimeInterval)interval;
- (BOOL)waitForAsyncOperationOrTimeoutWithDefaultInterval; // timeout: 10secs

- (void)assertAsyncOperationTimeout; // uses default interval

@end
